<html>
<head>
	<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
	<script type="text/javascript" src="js/ddaccordion.js"></script>


	<script type="text/javascript">	


		ddaccordion.init({
			headerclass: "silverheader", //Shared CSS class name of headers group
			contentclass: "submenu", //Shared CSS class name of contents group
			revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
			mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
			collapseprev: false, //Collapse previous content (so only one open at any time)? true/false
			defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
			onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
			animatedefault: false, //Should contents open by default be animated into view?
			persiststate: true, //persist state of opened contents within browser session?
			toggleclass: ["", "selected"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
			togglehtml: ["", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
			animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
			oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
			//do nothing
					},
			onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
				//do nothing
			}
						})


		</script>
		
		
		<style type="text/css">

.applemenu{
margin: 5px 0;
padding: 0;
width: 170px; /*width of menu*/
border: 1px solid #9A9A9A;
}

.applemenu div.silverheader {
background: black url(silvergradient.gif) repeat-x center left;
font: normal 12px Tahoma, "Lucida Grande", "Trebuchet MS", Helvetica, sans-serif;
color: white;
display: block;
position: relative; /*To help in the anchoring of the ".statusicon" icon image*/
width: auto;
padding: 5px 0;
padding-left: 8px;
text-decoration: none;
}


.applemenu div.silverheader a:visited, .applemenu div.silverheader a:active{
color: white;
}


.applemenu div.selected a, .applemenu div.silverheader a:hover{
background-image: url(silvergradientover.gif);
color: white;
}

.applemenu div.submenu{ /*DIV that contains each sub menu*/
background: white;
padding: 5px;

}

</style>
<script type="text/javascript">
function toggled(i)
{
	document.getElementById('alpha'+i).style.display = 'none';
	document.getElementById('DecPlc'+i).style.display = 'block';
}

function toggles(i)
{
	document.getElementById('DecPlc'+i).style.display = 'none';
	document.getElementById('alpha'+i).style.display = 'block';
}

function togglei(i)
{
	document.getElementById('alpha'+i).style.display = 'none';
	document.getElementById('DecPlc'+i).style.display = 'none';
}

</script>
<script type="text/javascript">

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
function create_menu()
{
	var NoOfElements = getCookie('NoOfElements');
	var i;
	for(i=1; i<=NoOfElements; i++)
	{
		var element = getCookie('element'+i);
		Token0 = element.indexOf("|", 0);
		var element_name = element.substring( 0, Token0 );  
		var element_type = element.substring( Token0+1, element.length );  
		make_menu(element_name,element_type,i);
	}
}
function make_menu(name,type,j)
{
	var url = getCookie('url');
	if(type == "TextField")
	{
		var newdiv = document.createElement('div');
		var content = "<div class=\"applemenu\" style=\"width:500px\"><div class=\"silverheader\">Name= " +name+ "&nbsp;&nbsp;&nbsp;Type= " +type+ "</div><div class=\"submenu\">";
		content += "<table><tr><td>DataType:</td><td colspan=\"3\"><input type=\"radio\" name=\""+name+"_datatype\" value=\"Integer\" onclick='togglei("+j+")'/> Integer<input type=\"radio\" name=\""+name+"_datatype\" value=\"Double\" onclick='toggled("+j+")'/> Double<input type=\"radio\" name=\""+name+"_datatype\" value=\"String\" onclick='toggles("+j+")'/> String</td></tr><tr><td>Range:</td><td><input type=\"text\" name=\""+name+"_From\" id=\""+name+"_From\"/></td><td>To</td><td><input type=\"text\" name=\""+name+"_To\" id=\""+name+"_To\"/></td></tr><tr><td>IsEmpty:</td><td colspan=\"3\"><input type=\"radio\" name=\""+name+"_Isempty\" value=\"1\"/>True<input type=\"radio\" name=\""+name+"_Isempty\" value=\"0\"/>False</td></tr><tr><td colspan=\"4\"><table id=\"DecPlc"+j+"\" style=\"display:none\"><tr><td width=\"134px\">Decimal Places:</td><td colspan=\"3\"><input type=\"text\" name=\""+name+"_decimalplaces\" id=\""+name+"_decimalplaces\"/></td></tr></table></td></tr><tr><td colspan=\"4\"><table id=\"alpha"+j+"\" style=\"display:none\"><tr><td>Only Alphabets:</td><td colspan=\"3\"><input type=\"radio\" name=\""+name+"_OnlyAlpha\" value=\"1\"/> True<input type=\"radio\" name=\""+name+"_OnlyAlpha\" value=\"0\"/> False</td></tr><tr><td>Alphabets + Special Characters:</td><td colspan=\"3\"><input type=\"radio\" name=\""+name+"_AlphaSplChar\" value=\"1\"/> True<input type=\"radio\"  name=\""+name+"_AlphaSplChar\" value=\"0\"/> False</td></tr><tr><td>Only Alpha-Numeric:</td><td colspan=\"3\"><input type=\"radio\" name=\""+name+"_OnlyAlphaNum\" value=\"1\"/> True<input type=\"radio\" name=\""+name+"_OnlyAlphaNum\" value=\"0\"/> False</td></tr><tr><td>Alpha-Numeric + Special Characters:</td><td colspan=\"3\"><input type=\"radio\" name=\""+name+"_AlphaNumSplChar\" value=\"1\"/> True<input type=\"radio\" name=\""+name+"_AlphaNumSplChar\" value=\"0\"/> False</td></tr></table></td></tr></table></div></div>";
		newdiv.innerHTML = content;
		
	
		document.body.appendChild(newdiv);
	}
	
	else if(type == "Radio")
	{

		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp1=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp1.onreadystatechange=function()
		  {
			if (xmlhttp1.readyState == 4 && xmlhttp1.status == 200) {
				
				var newdiv = document.createElement('div');
				var count_td = 0;
				var x = xmlhttp1.responseXML.getElementsByTagName("Button");
				var content_div = "<form name=\""+name+"\"><div class=\"applemenu\" style=\"width:500px\"><div class=\"silverheader\">Name= " +name+ "&nbsp;&nbsp;&nbsp;Type= " +type+ "</div><div class=\"submenu\"></div><table><tr><td width=\"75px\" valign=\"top\">Value:</td><td><table><tr>";
				 
				for (var i=0;i<x.length;i++)
				{
					if(count_td == 3)
					{
						content_div += "</tr><tr>";
						count_td = 0;
					}
					content_div += "<td width=\"125px\"><input type=\"checkbox\" name=\""+name+"_value\" value="+ x[i].getElementsByTagName("ButtonName")[0].childNodes[0].nodeValue +"></input>" +x[i].getElementsByTagName("ButtonName")[0].childNodes[0].nodeValue +"</td>" ;
					count_td += 1;
				}
				content_div += "</tr></table></td></tr></table></div></div></form>";
				newdiv.innerHTML = content_div;			
				document.body.appendChild(newdiv);
				
			}
			}
		var path = "ReturnNoOfElements_XML?url="+url+"&name=" +name+ "&type=Radio"; 
		xmlhttp1.open("GET",path,true);
		xmlhttp1.send();
	
	}
	
	else if(type == "CheckBox")
	{

		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				
				var newdiv = document.createElement('div');
				var count_td = 0;
				var x = xmlhttp.responseXML.getElementsByTagName("Checkbox");
				var content_div = "<div class=\"applemenu\" style=\"width:500px\"><div class=\"silverheader\">Name= " +name+ "&nbsp;&nbsp;&nbsp;Type= " +type+ "</div><div class=\"submenu\"></div><table><tr><td width=\"75px\" valign=\"top\">Value:</td><td><table><tr>"; 
				
				for (var i=0;i<x.length;i++)
				{
					if(count_td == 3)
					{
						content_div += "</tr><tr>";
						count_td = 0;
					}
					content_div += "<td width=\"125px\"><input type=\"checkbox\" name=\""+ name +"_value\" value="+ x[i].getElementsByTagName("CheckBoxName")[0].childNodes[0].nodeValue +"></input>" +x[i].getElementsByTagName("CheckBoxName")[0].childNodes[0].nodeValue +"&nbsp;</td>";
					count_td += 1;
				}
				content_div += "</tr></table></td></tr></table></div></div>";
				newdiv.innerHTML = content_div;			
				document.body.appendChild(newdiv);
			}
			}
		var path = "ReturnNoOfElements_XML?url="+url+"&name=" +name+ "&type=CheckBox"; 
		xmlhttp.open("GET",path,true);
		xmlhttp.send();

	}

	else if(type == "SelectList")
	{
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp2=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp2.onreadystatechange=function()
		  {
			if (xmlhttp2.readyState == 4 && xmlhttp2.status == 200) {
				
				var newdiv = document.createElement('div');
				var count_td = 0;
				var x = xmlhttp2.responseXML.getElementsByTagName("List");
				var content_div = "<div class=\"applemenu\" style=\"width:500px\"><div class=\"silverheader\">Name= " +name+ "&nbsp;&nbsp;&nbsp;Type= " +type+ "</div><div class=\"submenu\"></div><table><tr><td width=\"75px\" valign=\"top\">Value:</td><td><table><tr>"; 
				
				for (var i=0;i<x.length;i++)
				{
					if(count_td == 3)
					{
						content_div += "</tr><tr>";
						count_td = 0;
					}
					content_div += "<td width=\"125px\"><input type=\"checkbox\" name=\""+name+"_value\" value="+ x[i].getElementsByTagName("ListItem")[0].childNodes[0].nodeValue +"></input>" +x[i].getElementsByTagName("ListItem")[0].childNodes[0].nodeValue +"&nbsp;</td>";
					count_td += 1;
				}
				content_div += "</tr></table></td></tr></table></div></div>";
				newdiv.innerHTML = content_div;			
				document.body.appendChild(newdiv);
			}
			}
		var path = "ReturnNoOfElements_XML?url="+url+"&name=" +name+ "&type=SelectList"; 
		xmlhttp2.open("GET",path,true);
		xmlhttp2.send();
		
	}

	else if(type == "Hidden")
	{
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp3=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp3=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp3.onreadystatechange=function()
		  {
			if (xmlhttp3.readyState == 4 && xmlhttp3.status == 200) {
				
				var newdiv = document.createElement('div');
				var x = xmlhttp2.responseXML.getElementsByTagName("Item");
				var content_div = "<div class=\"applemenu\" style=\"width:500px\"><div class=\"silverheader\">Name= " +name+ "&nbsp;&nbsp;&nbsp;Type= " +type+ "</div><div class=\"submenu\"></div><table><tr><td width=\"75px\" valign=\"top\">Value:</td><td><table><tr>"; 
				content_div += "<td width=\"125px\">"+x.childNodes[0].nodeValue+"</td>";
				content_div += "</tr></table></td></tr></table></div></div>";
				newdiv.innerHTML = content_div;			
				document.body.appendChild(newdiv);
			}
			}
		var path = "ReturnNoOfElements_XML?url="+url+"&name=" +name+ "&type=Hidden"; 
		xmlhttp3.open("GET",path,true);
		xmlhttp3.send();
	}
}
</script>
<script type="text/javascript">
var Test_Request = "";
function get_elements()
{
	var NoOfElements = getCookie('NoOfElements');
	for(var i=1;i<=NoOfElements;i++)
	{
	var element = getCookie('element'+i);
	Token0 = element.indexOf("|", 0);
	var element_name = element.substring( 0, Token0 );  
	var element_type = element.substring( Token0+1, element.length );  
	if(element_type == "Radio")
		get_radio(element_name);
	else if(element_type == "SelectList")
		get_selectlist(element_name);
	else if(element_type == "CheckBox")
		get_checkbox(element_name);
	else if(element_type == "TextField")
		get_textfield(element_name);
	else if(element_type == "Hidden")
		get_hidden(element_name);
	}
	check();
	document.getElementById('next').disabled='true';
	
}
function get_radio(name)
{
	var c_value = name+"|Radio|";
	var check = document.getElementsByName(name+"_value");
	var count = 0;
	for (var i=0; i < check.length; i++)
	   {
	   if (check[i].checked)
	      {
		      if(count == 0)
	      		{
		      		c_value = c_value + check[i].value;
		      		count++;
	      		}
		      else if (count != 0)
		      		c_value =  c_value + ","+check[i].value;
	      }
	   }
	Test_Request += "||"+ c_value;
}

function get_textfield(name)
{
	var c_value = name+"|TextField|";
	var check = document.getElementsByName(name+"_datatype");
	var datatype = "";
	var count = 0;
	for (var i=0; i < check.length; i++)
	   {
	   if (check[i].checked)
	      {
		      datatype += check[i].value;
	      }
	   }
	   c_value += datatype;
	var Range_from = document.getElementById(name+"_From").value;
	var Range_to = document.getElementById(name+"_To").value;

	c_value += "|"+Range_from;
	c_value += "|"+Range_to;
	
	var isempty = document.getElementsByName(name+"_Isempty");
	for(var i=0;i<isempty.length;i++)
	{
		if(isempty[i].checked)
			c_value += "|"+isempty[i].value;
	}

	if(datatype == "Double")
	{
		c_value += "|" + document.getElementById(name+"_decimalplaces").value;
	}

	if(datatype == "String")
	{
		var OnlyAlpha = document.getElementsByName(name+"_OnlyAlpha");
		for(var i=0;i<OnlyAlpha.length;i++)
		{
			if(OnlyAlpha[i].checked)
				c_value += "|" + OnlyAlpha[i].value;
		}
		var AlphaSplChar = document.getElementsByName(name+"_AlphaSplChar");
		for(var i=0;i<AlphaSplChar.length;i++)
		{
			if(AlphaSplChar[i].checked)
				c_value += "|"+AlphaSplChar[i].value;
		}
		var OnlyAlphaNum = document.getElementsByName(name+"_OnlyAlphaNum");
		for(var i=0;i<OnlyAlphaNum.length;i++)
		{
			if(OnlyAlphaNum[i].checked)
				c_value += "|"+OnlyAlphaNum[i].value;
		}
		var AlphaNumSplChar = document.getElementsByName(name+"_AlphaNumSplChar");
		for(var i=0;i<AlphaNumSplChar.length;i++)
		{
			if(AlphaNumSplChar[i].checked)
				c_value += "|"+AlphaNumSplChar[i].value;
		}
	}
	Test_Request += "||"+ c_value;
}

function get_selectlist(name)
{
	var c_value = name+"|SelectList|";
	var check = document.getElementsByName(name+"_value");
	var count = 0;
	for (var i=0; i < check.length; i++)
	   {
	   if (check[i].checked)
	      {
		      if(count == 0)
	      		{
		      		c_value = c_value + check[i].value;
		      		count++;
	      		}
		      else if (count != 0)
		      		c_value =  c_value + ","+check[i].value;
	      }
	   }
	Test_Request += "||"+ c_value;
}

function get_checkbox(name)
{
	var c_value = name + "|CheckBox|";
	var check = document.getElementsByName(name+"_value");
	var count = 0;
	for (var i=0; i < check.length; i++)
	   {
	   if (check[i].checked)
	      {
		      if(count == 0)
	      		{
		      		c_value = c_value + check[i].value;
		      		count++;
	      		}
		      else if (count != 0)
		      		c_value =  c_value + ","+check[i].value;
	      }
	   }
	Test_Request += "||"+ c_value;
}
</script>
<script type="text/javascript">
function check()
{
	alert(Test_Request);
}</script>
</head>
<body>
<script type="text/javascript">
create_menu();</script>
<input type="button" value="Next>>" id="next" onclick="get_elements()"/>
</body>

</html>